package com.yxkj.syh.app.huarong.activities.user.car;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import androidx.lifecycle.MutableLiveData;

import com.syh.app.basic.base.view_model.BaseViewModel;
import com.syh.app.basic.utils.Tooast;
import com.syh.app.basic.utils.net.ApiObserver;
import com.trello.rxlifecycle2.android.ActivityEvent;
import com.yxkj.syh.app.huarong.bean.CarInfo;
import com.yxkj.syh.app.huarong.bean.CarInfoResponse;
import com.yxkj.syh.app.huarong.data_center.model.CommonModel;

/**
 * 创建者：SYH
 * 时间：2020/6/13 14:05
 * 编辑者：SYH、
 * 标签：
 * 补充说明：
 */
public class DriverCarInfoVM extends BaseViewModel<ActivityEvent> {

    public DriverCarInfoVM(@NonNull Application application) {
        super(application);
    }

    public ObservableField<String> ofForm1 = new ObservableField<>();
    public ObservableField<String> ofForm2 = new ObservableField<>();
    public ObservableField<String> ofForm3 = new ObservableField<>();
    public ObservableField<String> ofForm4 = new ObservableField<>();
    public ObservableField<String> ofForm5 = new ObservableField<>();
    public ObservableField<String> ofForm6 = new ObservableField<>();
    public ObservableField<String> ofForm7 = new ObservableField<>();
    public ObservableField<String> ofForm8 = new ObservableField<>();

    public MutableLiveData<CarInfo> mldCarInfo = new MutableLiveData<>();

    public void carInfo(String carId) {
        CommonModel.getCommonModel().carInfo(carId, mLifecycleProvider.bindToLifecycle(), new ApiObserver<CarInfoResponse>() {
            @Override
            public void onSuccess(CarInfoResponse carInfoResponse) {
                mldCarInfo.setValue(carInfoResponse.getData());
            }

            @Override
            public void onFailed(int code, String msg) {
                Tooast.warning(msg);
            }
        });
    }

}
